<?php
/**
 * Captcha controller
 * 
 * @author Konstantin Shamko <konstantin.shamko@gmail.com> 
 * @version 0.0.1
 * @copyright  Copyright (c) 2009 Konstantin Shamko
 * @category VaselinEngine
 * @package Default Module
 * @subpackage Controller
 * @license  New BSD License
 *
 */
class CaptchaController extends Zend_Controller_Action {

	/**
	 * Regenerates CAPTCHA and return it via JSON. Used by captcha smarty plugin 
	 *
	 */
	public function regeneratecaptchaAction(){
		include_once(HOME_DIR.'Libs/smarty/plugins/function.captcha.php');		
		ob_start();
		$view = Zend_Registry::get('view');
		smarty_function_captcha(array('name'=>$this->_request->getParam('name')), $view);	
		$result = ob_get_contents();
		ob_clean();		
		echo Zend_Json::encode(array('content'=>$result));
		die();
	}		
}